﻿using Bids.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;
namespace Bids.Core.DomainObjects
{
	/// <summary>
	/// 投稿列表
	/// </summary>
	[Serializable]
    public class Event : IEntity
	{
		
		/// <summary>
		/// 
		/// </summary>
        public virtual int ID { set; get; }
		/// <summary>
		/// 动作发生者
		/// </summary>
        public virtual string ActionUserName { set; get; }
		/// <summary>
		/// 动作
		/// </summary>
        public virtual string Action { set; get; }
		/// <summary>
		/// 目标对象
		/// </summary>
        public virtual string TargetUserName { set; get; }
		/// <summary>
		/// 目标
		/// </summary>
        public virtual string Target { set; get; }
		/// <summary>
		/// 发生时间
		/// </summary>
        public virtual DateTime HappenedTime { set; get; }

        public static MappingConfiguration<Event> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<Event>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.ActionUserName,
                t.Action,
                t.TargetUserName,
                t.Target,
                t.HappenedTime
            }).ToTable("Events");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            //threadMapping.HasAssociation(t => t.Contribution).WithOpposite(d => d.ContributionItems).HasConstraint((t,d)=>t.ContributionId == d.ID);
            //threadMapping.HasAssociation(t => t.Login).WithOpposite(t=>t.ProductOrder).HasConstraint((p, l) => p.LoginID == l.ID);
            //threadMapping.HasAssociation(t => t.Forum).WithOpposite(f => f.Threads).HasConstraint((t, f) => t.ForumId == f.Id);
            //threadMapping.HasAssociation(t => t.User).WithOpposite(u => u.Threads).HasConstraint((t, u) => t.UserId == u.Id);

            return threadMapping;
        }

	}
}

